import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.util.*; 
import java.io.*; 
import java.math.*;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;


public class ds1 {

	@SuppressWarnings("null")
	public static void main(String[] args) throws IOException {
		Scanner inScanner = new Scanner(System.in);
		System.out.print("File Name: ");
//		String fName = inScanner.nextLine();
		String fName = "1m.dat";
		
		long time1=System.currentTimeMillis();
		File fFile = new File(fName);
		File qFile = new File("q.dat");
		FileInputStream fIS = new FileInputStream(fFile);
		Scanner	qScanner = new Scanner(qFile);
		BufferedWriter out = new BufferedWriter(new FileWriter("result2.dat"));
		byte[] fByte = new byte[(int) fFile.length()];
		int check=3;
		String q;
		
		System.out.print("reading file . . .");
		fIS.read(fByte);
		System.out.println(" Done !!");
		System.out.print("searching file . . .");
		out.write("Mr. Kamonwat Rojjanadechakul #5480366\n//BruteForce");

		while(qScanner.hasNext()){
			q=qScanner.next();
			out.write("\n"+fName+","+q);
			byte[] qByte = new byte[q.length()];			
			qByte = q.getBytes();
			for(int i=0; i<=fByte.length-qByte.length; i++){
				for(int j=0; j<qByte.length; j++){
					if(fByte[i+j]==qByte[j]){
						check=1;
					}
					else{
						check=0;
						break;
					}
				}
				if(check==1){
					out.write(","+i);
				}			
			}
		}
		qScanner.close();
		inScanner.close();

		System.out.println(" Done !!\n\ntotal time: "+(System.currentTimeMillis()-time1)+" s");
		out.write("\n\ntotal time: "+(System.currentTimeMillis()-time1)+" ms");
		out.close();
	}
}
